<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <link rel="stylesheet" type="text/css" href="../../css/common/reset.css">
    <link rel="stylesheet" type="text/css" href="../../css/register/index.css">
</head>
<body>

<div class="biaodan">
    <form class="form">
        <ul>
            <li class="user">
                <span class="uimg">SIM号码</span>
                <input type="text" placeholder="请输入要绑定的备卡号"  id="sim">
            </li>
            <li class="user" >
                <span class="uimg">真实姓名</span>
                <input type="text" placeholder="请输入真实姓名" id="name">
            </li>
            <li class="user">
                <span class="uimg">手机号码</span>
                <input type="tel" placeholder="请输入手机号码"  id="phone">
            </li>
        </ul>

    </form>
</div>
<a class="payment">
    <div class="submit">提交</div>
</a>
<div class="modal">
    <div class="input_prompt">
        <div class="title">
            <span>信息</span>
            <img src="../../image/close.png" alt="" class="close">
        </div>
        <div class="weep">
            <img id="icon" src="../../image/weep.png" alt="">
            <span id = "result">注册失败</span>
        </div>
        <div class="btn close">确定</div>
    </div>
</div>
<script type="text/javascript" src="../../js/jquery-1.12.3.min.js"></script>
<script type="text/javascript">
    $(function(){
        var modal = $('.modal')
        $('.submit').click(function(){
            var sim = $('#sim').val();
            var name = $('#name').val();
            $.ajax({
                type:"put",
                url: "/api/user/register",
                contentType : 'application/json',
                data:JSON.stringify({
                    "sim":sim,
                    "realName":name,
                    "telephone":$("#phone").val().replace(/\s/g, "")
                }),
                dataType:"json",
                success: function (data) {
                    if(data.code=="1001"){
                        document.getElementById('icon').src = "../../image/smiling.png";
                    }
                    document.getElementById("result").innerHTML=data.msg;
                    modal.fadeIn().show()
                    if(data.code=="1001"){
                        self.location="/api/index";
                    }
                }

            });
        })
        $('.close').click(function(){
            modal.hide()
        })
    })
</script>
</body>

</html>
